
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.hxci.web.bean.Conn" %>
<%@include file="/public.jsp"%><%--
  Created by IntelliJ IDEA.
  User: 刘跃波1
  Date: 2025/6/24
  Time: 8:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/styless.css">
</head>
<body>
<FORM>
<%
    String readername=request.getParameter("readername");
    String bookid=request.getParameter("bookid");
    Statement stmt=conn.createStatement();
    String sql="SELECT * FROM borrowings t WHERE " +" 1=1 ";
//    构建基础查询语句，方便后续动态添加AND条件
    if(null!=readername && !"".equals(readername)){
        sql=sql+" AND  t.readername LIKE '%"+readername+"%' ";
    }
    if(null!=bookid && !"".equals(bookid)){
        sql=sql+" AND  t.bookid = '"+bookid+"' ";
    }
    ResultSet rs=stmt.executeQuery(sql);
%>
<table align="center">
    <h1 align="center">欢迎进入借阅信息</h1>
<tr>
    <td align="center">借阅人：<input type="text" name="readername" id="readername"></td>
    <td align="center">图书编号：<input type="text" name="bookid" id="bookid"></td>
</tr>
    <tr>
        <td align="center" colspan="2">
            <input type="submit" value="查询">
            <input type="button" value="添加" onclick="rent_add()">

        </td>
    </tr>
</table>
<hr>
    <table align="center" width="80%" berder="1" >
    <tr align="center">
        <td>ID</td>
        <td>借阅人</td>
        <td>图书编号</td>
        <td>图书名称</td>
        <td>借阅时间</td>
        <td>预计归还时间</td>
        <td>借阅状态</td>
        <td>联系方式</td>
        <td>操作</td>

    </tr>
    <tbody id="devList">
    <tr align="center">
<%
    while(rs.next()) {
%>
    <tr>
        <td><%=rs.getString("Borrowingid")%></td>
        <td><%=rs.getString("readername")%></td>
        <td><%=rs.getString("bookid")%></td>
        <td><%=rs.getString("bookname")%></td>
        <td><%=rs.getString("Borrowingtime")%></td>
        <td><%=rs.getString("returntime")%></td>
        <td><%=rs.getString("status")%></td>
        <td><%=rs.getString("phone")%></td>
        <td>
            <input type="button" value="修改" onclick="rent_update(<%=rs.getString("Borrowingid")%>)">
            <input type="button" value="删除" onclick="rent_delete(<%=rs.getString("Borrowingid")%>)">
            <input type="button" value="归还" onclick="returnDev(<%=rs.getString("Borrowingid")%>)">
            <input type="button" value="续借" onclick="renewDev(<%=rs.getString("Borrowingid")%>,<%=rs.getString("returntime")%>)">
            <input type="button" value="逾期" onclick="overrunDev(<%=rs.getString("Borrowingid")%>)">
        </td>
<%}%>
    </tr>

    </tr>
    </tbody>
</table>
</FORM>
<script>
    function rent_add() {
        window.location.href = "rent/rent_add.jsp";
    }
    function rent_update(Borrowingid) {
        window.location.href = "rent/rent_update.jsp?Borrowingid="+Borrowingid;
    }
    function rent_delete(Borrowingid) {
        window.location.href = "rent/rent_delete.jsp?Borrowingid="+Borrowingid;
    }
    function returnDev(Borrowingid) {
        window.location.href = "status.jsp?Borrowingid="+Borrowingid+"&status=已归还";
    }
    function renewDev(Borrowingid) {
        window.location.href = "status.jsp?Borrowingid="+Borrowingid+"&status=续借";
    }
    function overrunDev(Borrowingid) {
        window.location.href = "status.jsp?Borrowingid="+Borrowingid+"&status=逾期";
    }

</script>
</body>
</html>
